package GDoc::SiteConf;

use strict;
use warnings;

use YAML::XS;
use Carp 'croak';

use GDoc::Const 'SITE_CONF';

our %CONF_CACHE;

sub get_conf { 
    my $class = shift;
    my $name = shift;

    return $CONF_CACHE{$name} if exists $CONF_CACHE{$name};

    my $tmp = do { 
        local $/; 
        open my $fh, '<', SITE_CONF or die "Can't open " . SITE_CONF . " $!";
        YAML::XS::Load( <$fh> );
    };

    if ( $tmp->{$name} ) { 
        %CONF_CACHE = %$tmp;
        return $CONF_CACHE{$name};
    }

    croak "No conf entry $name";
}

1;

    
